package com.example.test.springdemo.util;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ：吉金武
 * @ClassName RemortIPUtils
 * @date ：2022/1/22 - 11:28
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description:
 **/
public class RemortIPUtils {

    /**
     * 获取当前用户访问的ip
     * @param request
     * @return
     */
    public static String getRemortIP(HttpServletRequest request) {
        if (request.getHeader("x-forwarded-for") == null) {
            return request.getRemoteAddr();
        }
        return request.getHeader("x-forwarded-for");
    }
}

